<nav aria-label="Page navigation" style="display: flex;">
    <ul class="pagination" style="margin:0;padding:0;">
      <li>
        <a href="{if $pagenum==1}javascript:;{else}{$action}?{if $page_query}{$page_query}&{/if}page={$pagenum-1}{/if}" aria-label="Previous">
          <span aria-hidden="true"><</span>
        </a>
      </li>
        {if $pagenum-5 < 1 }
          {$prevStart = 1 }
        {else}
          {$prevStart = $pagenum - 5 }
        {/if}
        {if $prevStart > 5 }
          <li><a href="{$action}?{if $page_query}{$page_query}&{/if}page=1">1</a></li>
          <li class="disabled"><a href="javascript:;">...</a></li>
        {/if}
        {section loop=$pagenum start=$prevStart name=pagePrev}
          {if $smarty.section.pagePrev.index > 0}
            <li><a href="{$action}?{if $page_query}{$page_query}&{/if}page={$smarty.section.pagePrev.index}">{$smarty.section.pagePrev.index}</a></li>
          {/if}
        {/section}
        <li class="active"><a href="javascript:;">{$pagenum}</a></li>
        {section loop=$pagenum+5 start=$pagenum+1 name=pageNext}
          {if $smarty.section.pageNext.index<=$totalPage}
            <li><a href="{$action}?{if $page_query}{$page_query}&{/if}page={$smarty.section.pageNext.index}">{$smarty.section.pageNext.index}</a></li>
          {/if}
        {/section}
        {if $pagenum < $totalPage-10 }
          <li class="disabled"><a href="javascript:;">...</a></li>
          <li><a href="{$action}?{if $page_query}{$page_query}&{/if}page={$totalPage}">{$totalPage}</a></li>
        {/if}
        <li>
          <a href="{if $pagenum>=$totalPage || $totalPage==0}javascript:;{else}{$action}?{if $page_query}{$page_query}&{/if}page={$pagenum+1}{/if}" aria-label="Next">
            <span aria-hidden="true">></span>
          </a>
        </li>
    </ul>
    <div style="display:inline-block;position: relative;margin:0 20px;">
      <span>前往</span>
      <input type="number" value="{$pagenum}" class="form-control" role-input="num" autocomplete="off" onkeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" style="ime-mode:Disabled;display:inline-block;width: 50px;">
      <span>页</span>
    </div>
</nav>
<script>
function UpdateUrlParam(name, val) {
    var thisURL = document.location.href;
    if (thisURL.indexOf(name + '=') > 0) {
        var v = getUrlParam(name);
        if (v != null) {
            thisURL = thisURL.replace(name + '=' + v, name + '=' + val);
        } else {
            thisURL = thisURL.replace(name + '=', name + '=' + val);
        }
    }else {
        if (thisURL.indexOf('?') > 0) {
            thisURL = thisURL + '&' + name + '=' + val;
        } else {
            thisURL = thisURL + '?' + name + '=' + val;
        }
    }
    window.location.href = thisURL;
}
function getUrlParam(name) {
    var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]);
    return null;
}
$('body')
    .on('blur','[role-input="num"]',function(){
        var getNum = $(this).val();
        UpdateUrlParam('page',getNum);
    })
</script>
